import { defineConfig } from "vite";
import { resolve } from "path";
import uni from "@dcloudio/vite-plugin-uni";
import AutoImport from 'unplugin-auto-import/vite';
import Tailwind from '@uni-helper/vite-plugin-uni-tailwind'

// https://vitejs.dev/config/
export default defineConfig({
  server: {
    open: true
  },
  resolve: {
    alias: {
      '@': resolve(__dirname, './src'),
    },
  },
  define: {
    'process.env': {
      NODE_ENV: process.env.NODE_ENV
    }
  },
  plugins: [
    uni(),
    AutoImport({
      imports: ['vue', 'uni-app', 'pinia'],
      dts: './src/auto-imports.d.ts',
      vueTemplate: true,
    }),
    Tailwind()
  ],
  css: {
    preprocessorOptions: {
      scss: {
        // 消除一些不必要的警告
        api: 'modern-compiler',
        silenceDeprecations: ['legacy-js-api', 'import'],
      }
    },
    postcss: {
      plugins: [
        require('tailwindcss'),
        require('autoprefixer')
      ]
    }
  },
  optimizeDeps: {
    exclude: ['sard-uniapp'],
  },
});
